import 'package:flutter/material.dart';
import 'simple_dialog_demo.dart';
import 'snack_bar _demo.dart';
import 'expansion_panel_demo.dart';
import 'bottom_sheet_demo.dart';
import 'alert_dialog_demo.dart';

class DialogListViewDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return DialogListView();
  }
}

class DialogListView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView(
      children: <Widget>[
        DialogListViewItem(
          title: 'SimpleDialogDemo',
          page: SimpleDialogDemo(),
        ),
        DialogListViewItem(
          title: 'SnackBarDemo',
          page: SnackBarDemo(),
        ),
        DialogListViewItem(
          title: 'ExpansionPanelDemo',
          page: ExpansionPanelDemo(),
        ),
        DialogListViewItem(
          title: 'BottomSheetDemo',
          page: BottomSheetDemo(),
        ),
        DialogListViewItem(
          title: 'AlertDialogDemo',
          page: AlertDialogDemo(),
        ),
      ],
    );
  }
}

class DialogListViewItem extends StatelessWidget {
  final String title;

  final Widget page;

  DialogListViewItem({this.title, this.page});

  @override
  Widget build(BuildContext context) {
    return ListTile(
      title: Text(title),
      onTap: () {
        Navigator.of(context)
            .push(MaterialPageRoute(builder: (context) => page));
      },
    );
  }
}
